package com.atguigui.leetcode1;

/**
 * 1375. 二进制字符串前缀一致的次数
 * <p>
 * Project: leetcode
 * Package: com.atguigui.leetcode1
 * Version: 1.0
 * <p>
 * Created by WJX on 2023/6/14 10:43
 */
public class P1375NumberOfTimesBinaryStringIsPrefixAligned {

    public static void main(String[] args) {
        Solution solution = new P1375NumberOfTimesBinaryStringIsPrefixAligned().new Solution();
    }


    class Solution {
        public int numTimesAllBlue(int[] flips) {
            int n = flips.length;
            int max = 0, ans = 0;
            for (int i = 0; i < n; i++) {
                max = Math.max(max, flips[i]);
                if (i + 1 == max) ans++;
            }

            return ans;
        }
    }
}
